{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import datetime\n",
    "import warnings; warnings.simplefilter('ignore')\n",
    "import QUANTAXIS as QA\n",
    "import os\n",
    "from  mfm_operator import *\n",
    "import factors_definition_1d\n",
    "import scipy.stats as stats\n",
    "factor_path='E:\\\\Users\\\\Desktop\\\\factorhub\\\\factors'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "factor=factors_definition_1d.factors()\n",
    "function_str_list=[\"factor.\"+fac  for fac in dir(factor) if fac[0:5]=='alpha']\n",
    "for function_str in function_str_list:\n",
    "    try:\n",
    "        eval(function_str+\"()\").to_pickle(factor_path+'\\\\'+function_str[7:]+'.pkl')\n",
    "    except:\n",
    "        print('error:' ,function_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# sum_factors_list = [pd.read_pickle(factor_path+\"\\\\\"+i).rank(axis=1) for i in os.listdir(factor_path)]\n",
    "# sum_factors_df=pd.DataFrame()\n",
    "# for i in sum_factors_list:\n",
    "#     sum_factors_df=sum_factors_df.add(i,fill_value=0)\n",
    "# sum_factors_df.to_pickle(\"sum_factors_1d.pkl\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0-final"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}